package com.amox.uitest.adapter;

import org.dom4j.Element;

import com.amox.uitest.common.KeyWord;
import com.amox.uitest.tcase.BaseTestCase;

import ognl.Ognl;

public class LetAdapter extends BaseAdapter<Boolean> {

	public LetAdapter(BaseTestCase uitest) {
		super(uitest);
	}

	@Override
	public Boolean adapter(Element element) throws Exception {
		String id = element.attributeValue(KeyWord.id.name());
		String value = element.getStringValue();
		if(value.indexOf('#') >= 0) {
			value = (String)Ognl.getValue(value, BaseTestCase.context, BaseTestCase.context.getRoot());
		}
		BaseTestCase.context.put(id, value);
		return true;
	}
	
}
